def calculate_rating(constant: float, score: int) -> float:
    """
    根据定数和分数计算Rating值
    
    Args:
        constant: 歌曲定数
        score: 游玩分数
        
    Returns:
        float: 计算得到的Rating值
        
    Rating计算规则:
    - 1009000+: constant + 2.15
    - 1007500-1009000: constant + 2.0 + 0.15 * (score - 1007500) / 1500
    - 1005000-1007500: constant + 1.5 + 0.5 * (score - 1005000) / 2500
    - 1000000-1005000: constant + 1.0 + 0.5 * (score - 1000000) / 5000
    - 975000-1000000: constant + (score - 975000) / 25000
    - 925000-975000: constant - 3.0 + 3.0 * (score - 925000) / 50000
    - 900000-925000: constant - 5.0 + 2.0 * (score - 900000) / 25000
    - 800000-900000: (constant - 5.0) / 2 + (constant - 5.0) / 2 * (score - 800000) / 100000
    - 500000-800000: ((constant - 5.0) / 2) * (score - 500000) / 300000
    - <500000: 0
    """
    if constant == 0:
        return 0

    # 1009000+
    if score >= 1009000:
        return constant + 2.15

    # 1007500-1009000
    elif score >= 1007500:
        return constant + 2.0 + 0.15 * (score - 1007500) / 1500

    # 1005000-1007500
    elif score >= 1005000:
        return constant + 1.5 + 0.5 * (score - 1005000) / 2500

    # 1000000-1005000
    elif score >= 1000000:
        return constant + 1.0 + 0.5 * (score - 1000000) / 5000

    # 975000-1000000
    elif score >= 975000:
        return constant + (score - 975000) / 25000

    # 925000-975000
    elif score >= 925000:
        return constant - 3.0 + 3.0 * (score - 925000) / 50000

    # 900000-925000
    elif score >= 900000:
        return constant - 5.0 + 2.0 * (score - 900000) / 25000

    # 800000-900000
    elif score >= 800000:
        return (constant - 5.0) / 2 + (constant - 5.0) / 2 * (score - 800000) / 100000

    # 500000-800000
    elif score >= 500000:
        return ((constant - 5.0) / 2) * (score - 500000) / 300000

    # <500000
    else:
        return 0


def calculate_rating_by_score(score: int, cur_rating: float) -> float:
    """
    根据分数和当前Rating反推歌曲定数
    
    Args:
        score: 游玩分数
        cur_rating: 当前Rating值
        
    Returns:
        float: 计算得到的歌曲定数,精确到小数点后1位
        
    计算规则:
    - 1009000+: cur_rating - 2.15
    - 1007500-1009000: cur_rating - 2 - (score - 1007500) / 10000
    - 1005000-1007500: cur_rating - 1.5 - (score - 1005000) / 5000
    - 1000000-1005000: cur_rating - 1 - (score - 1000000) / 10000
    - 990000-1000000: cur_rating - 0.6 - (score - 990000) / 25000
    - 975000-990000: cur_rating - (score - 975000) / 25000
    - 925000-975000: cur_rating + 3 - (score - 925000) / 50000 * 3
    - 900000-925000: cur_rating + 5 - (score - 900000) / 25000 * 2
    - 800000-900000: cur_rating / (0.5 + (score - 800000) / 200000) + 5
    - 500000-800000: cur_rating * 2 / ((score - 500000) / 300000) + 5
    - <500000: 0
    """
    # 1009000+
    if score >= 1009000:
        result = cur_rating - 2.15

    # 1007500-1009000
    elif score >= 1007500:
        result = cur_rating - 2 - (score - 1007500) / 10000

    # 1005000-1007500
    elif score >= 1005000:
        result = cur_rating - 1.5 - (score - 1005000) / 5000

    # 1000000-1005000
    elif score >= 1000000:
        result = cur_rating - 1 - (score - 1000000) / 10000

    # 990000-1000000
    elif score >= 990000:
        result = cur_rating - 0.6 - (score - 990000) / 25000

    # 975000-990000
    elif score >= 975000:
        result = cur_rating - (score - 975000) / 25000

    # 925000-975000
    elif score >= 925000:
        result = cur_rating + 3 - (score - 925000) / 50000 * 3

    # 900000-925000
    elif score >= 900000:
        result = cur_rating + 5 - (score - 900000) / 25000 * 2

    # 800000-900000
    elif score >= 800000:
        result = cur_rating / (0.5 + (score - 800000) / 200000) + 5

    # 500000-800000
    elif score >= 500000:
        result = cur_rating * 2 / ((score - 500000) / 300000) + 5

    # <500000
    else:
        return 0

    return round(result * 10) / 10
